﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.PlayerReputationChangesLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using System.Linq;
using TaleWorlds.CampaignSystem.CharacterDevelopment;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class PlayerReputationChangesLogEntry : LogEntry
  {
    [SaveableField(410)]
    private readonly TraitObject _trait;
    [SaveableField(411)]
    private readonly List<Hero> _companionsInParty;
    [SaveableField(412)]
    private readonly ActionNotes _note;
    [SaveableField(413)]
    private readonly Hero _referenceHero;

    internal static void AutoGeneratedStaticCollectObjectsPlayerReputationChangesLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this._trait);
      collectedObjects.Add((object) this._companionsInParty);
      collectedObjects.Add((object) this._referenceHero);
    }

    internal static object AutoGeneratedGetMemberValue_trait(object o)
    {
      return (object) ((PlayerReputationChangesLogEntry) o)._trait;
    }

    internal static object AutoGeneratedGetMemberValue_companionsInParty(object o)
    {
      return (object) ((PlayerReputationChangesLogEntry) o)._companionsInParty;
    }

    internal static object AutoGeneratedGetMemberValue_note(object o)
    {
      return (object) ((PlayerReputationChangesLogEntry) o)._note;
    }

    internal static object AutoGeneratedGetMemberValue_referenceHero(object o)
    {
      return (object) ((PlayerReputationChangesLogEntry) o)._referenceHero;
    }

    public PlayerReputationChangesLogEntry(TraitObject trait, Hero referenceHero, ActionNotes note)
    {
      this._trait = trait;
      this._referenceHero = referenceHero;
      this._companionsInParty = Hero.MainHero.CompanionsInParty.ToList<Hero>();
      this._note = note;
    }

    public override void GetConversationScoreAndComment(
      Hero talkTroop,
      bool findString,
      out string comment,
      out ImportanceEnum score)
    {
      score = ImportanceEnum.Zero;
      comment = "";
      if (!this._companionsInParty.Contains(talkTroop))
        return;
      if (talkTroop.GetTraitLevel(DefaultTraits.Honor) > 0 && this._trait == DefaultTraits.Honor)
      {
        if (this._note == ActionNotes.QuestSuccess)
        {
          MBTextManager.SetTextVariable("COMMENT_REFERENCE_HERO", this._referenceHero.Name, false);
          comment = "str_comment_companion_on_honor_for_quest_success";
          score = ImportanceEnum.SomewhatImportant;
        }
        else if (this._note == ActionNotes.QuestBetrayal)
        {
          MBTextManager.SetTextVariable("COMMENT_REFERENCE_HERO", this._referenceHero.Name, false);
          comment = "str_comment_companion_on_honor_for_quest_betrayal";
          score = ImportanceEnum.SomewhatImportant;
        }
      }
      if (talkTroop.GetTraitLevel(DefaultTraits.Generosity) <= 0 || this._trait != DefaultTraits.Generosity || this._note != ActionNotes.PartyTakenCareOf)
        return;
      comment = "str_comment_companion_on_generosity_for_party_morale";
      score = ImportanceEnum.SomewhatImportant;
    }

    public override string ToString() => nameof (PlayerReputationChangesLogEntry);
  }
}
